<template>
	<!-- 规格 -->
	<view class="cu-modal bottom-modal" @touchmove.stop.prevent="" :class="{ show: showModal }"
		@tap.stop="showModal = false">
		<view class="cu-dialog" @tap.stop style="border-radius: 30rpx 30rpx 0 0;">
			<view class="shop-modal page_box" style="height:800rpx">
				<text class="u-iconfont uicon-close-circle-fill close-icon" @tap.stop="showModal = false"></text>
				<!-- 商品卡片-->
				<view class="top u-flex modal-head__box">
					<image class="shop-img" :src="goodsInfo.img"
						mode="aspectFill"></image>
					<view class=" goods-box u-flex-col u-row-between">
						<view class="u-flex u-row-between goods-bottom">
							<view class="price-box u-flex">
								<view>￥{{ goodsInfo.price }}</view>
							</view>
							<!-- <text class="stock">库存999+</text> -->
						</view>
						<view class="goods-title u-ellipsis-2">已选：{{versionStr}}</view>
						<view class="select-combo">
							<!-- 已选：{{versionStr}} -->
						</view>
						<!-- <view class="select-combo">
							商品：{{commodityStr}}
						</view> -->
						
					</view>
				</view>

				<!-- 规格选项 -->
				<scroll-view scroll-y class="content_box">
					<!-- <view class="select-box u-flex-col u-row-left" >
						<view class="type-title u-flex">套餐</view>
						<view class="tag-box u-flex u-flex-wrap">
							<button class="tag u-reset-button" v-for="(thali, thaliIndex) in currentSkuArray.params" :key="thaliIndex"
							:class="{ 'tag-active': indexs.tcInex == thaliIndex}"
							:style="indexs.tcInex == thaliIndex?'border: 1rpx solid '+$COLOR+';color: '+$COLOR+';background-color:#fff' : ''"
							@tap="chooseSku('params', thaliIndex)" >
								{{ thali.name }}
							</button>
						</view>
					</view> -->
					
					<!-- <view class="select-box u-flex-col u-row-left" >
						<view class="type-title u-flex">规格</view>
						<view class="tag-box u-flex u-flex-wrap">
							<button class="tag u-reset-button" v-for="(color, colorIndex) in goodsInfo.params" :key="colorIndex"
							:class="{ 'tag-active': indexs.clIndex == colorIndex}"
							:style="indexs.clIndex == colorIndex?'border: 1rpx solid '+$COLOR+';color: '+$COLOR+';background-color:#fff' : ''"
							@tap="chooseSku('colors', colorIndex)" >
								{{ color.name }}
							</button>
						</view>
					</view> -->
					
					<view class="select-box u-flex-col u-row-left" >
						<view class="type-title u-flex">支付方式</view>
						<view class="tag-box u-flex u-flex-wrap">
							<button class="tag u-reset-button" 
							:class="{ 'tag-active': aliChecked == 2}"
							:style="aliChecked == 2?'border: 1rpx solid '+$COLOR+';color: '+$COLOR+';background-color:#fff' : ''"
							@tap="checkedTap(2)">
								阶段付
							</button>
							
							<button class="tag u-reset-button"
							:class="{ 'tag-active': aliChecked == 1}"
							:style="aliChecked == 1?'border: 1rpx solid '+$COLOR+';color: '+$COLOR+';background-color:#fff' : ''"
							@tap="checkedTap(1)">
								全额支付
							</button>
						</view>
					</view>
					
					<view class="select-box u-flex-col u-row-left" >
						<view class="type-title u-flex">周期</view>
						<view class="tag-box u-flex u-flex-wrap">
							<button class="tag u-reset-button" v-for="(term, termIndex) in goodsInfo.params[indexs.tcInex].term_list" :key="termIndex"
							:class="{ 'tag-active': indexs.zqIndex == termIndex}"
							:style="indexs.zqIndex == termIndex?'border: 1rpx solid '+$COLOR+';color: '+$COLOR+';background-color:#fff' : ''"
							@tap="chooseSku('termList', termIndex)">
								{{ term.title }}
							</button>
						</view>
					</view>
					
					<view class="select-box u-flex-col u-row-left" >
						<view class="type-title u-flex">颜色</view>
						<view class="tag-box u-flex u-flex-wrap">
							<button class="tag u-reset-button" v-for="(item, index) in goodsInfo.params[indexs.tcInex].term_list[indexs.zqIndex].skuObj" :key="index"
							:class="{ 'tag-active': indexs.clIndex == index}"
							:style="indexs.clIndex == index?'border: 1rpx solid '+$COLOR+';color: '+$COLOR+';background-color:#fff' : ''"
							@tap="chooseSku('colors', index)">
								{{ item.name }}
							</button>
						</view>
					</view>
					
					<view class="select-box u-flex-col u-row-left" >
						<view class="type-title u-flex">版本</view>
						<view class="tag-box u-flex u-flex-wrap">
							<button class="tag u-reset-button" v-for="(item, index) in goodsInfo.params[indexs.tcInex].term_list[indexs.zqIndex].skuObj[indexs.clIndex].list" :key="index"
							:class="{ 'tag-active': indexs.bbIndex == index}"
							:style="indexs.bbIndex == index?'border: 1rpx solid '+$COLOR+';color: '+$COLOR+';background-color:#fff' : ''"
							@tap="chooseSku('specificationsList', index)">
								{{ item.tit }}
							</button>
						</view>
					</view>
					
					<view class="select-box u-flex-col u-row-left" v-if="goodsInfo.smash != 0">
						<view class="type-title u-flex">碎屏保障</view>
						<view class="tag-box u-flex u-flex-wrap">
							<button class="tag u-reset-button"
							:style="indexs.insIndex != 0 ?'border: 1rpx solid '+$COLOR+';color: '+$COLOR+';background-color:#fff' : ''"
							:class="{ 'tag-active': indexs.insIndex != 0}" @tap="chooseSku('insIndex', goodsInfo.smash)">
								碎屏保障￥{{ goodsInfo.smash / 100 }}
							</button>
						</view>
					</view>

					<!-- 计步器 -->
					<!-- <view class="buy-num-box u-flex u-row-between">
						<view class="num-title">购买数量</view>
						<u-number-box v-model="goodsNum" :min="1" :step="1" :max="maxStep" 
							:long-press="false"></u-number-box>
					</view> -->
					
					<!-- <view class="selectNumWrap">
					  <view style="display:flex">
						<image style="width:45rpx;height:45rpx; margin-top:10rpx;margin-right:15rpx;" src="https://jijiangjun.oss-cn-hangzhou.aliyuncs.com/upload/20240424/db72801f31e440659022c07bd2653590.png" />
						  <view class="box-title">
							先享后付 
							<text class="recommend">推荐</text>
							<view style="margin-left:30rpx;">开通享<text style="color:#e8d59d;margin-left:10rpx;">0元下单先用</text></view>
						  </view>
					  </view>
					  <view >
						<text class="buttonRecommend" @tap="confirmBuy(0)">立即申请</text>
					  </view>
					</view> -->
					
					<!-- <view class="selectNumWrap">
					<view style="display:flex">
					<image style="width:45rpx;height:45rpx; margin-top:10rpx;margin-right:15rpx;" src="https://jijiangjun.oss-cn-hangzhou.aliyuncs.com/upload/20240424/6f90604bc40e48c6b0da9907c13e8f59.png" />
					  <view class="box-title" style="margin-top:10rpx;">
						支付宝全额支付
					  </view>
					</view>
					<view>
						  <view class="checkbox-circle"  @tap="checkedTap">
						  <image v-if="aliChecked" class="select_true" mode="scaleToFill" :src="$IMAGE_URL + '/gouxuan_icon.png'" />
						  </view>
					</view>
					</view> -->
					
				</scroll-view>

				<!-- 功能按钮 保留直接支付的情况下 -->
				<!-- <view class="btn-box foot_box u-flex u-row-between">
					<button class="u-reset-button cu-btn save-btn" 
					:style="{background:'linear-gradient(180deg, ' + this.$COLOR + ' 0%, '+ this.$CHANGEA+' 100%)'} "
						@tap="confirmBuy(1)">确认</button>
				</view> -->
				<view class="btn-box foot_box u-flex u-row-between">
					<button class="u-reset-button cu-btn save-btn" 
					:style="{background:'linear-gradient(180deg, ' + this.$COLOR + ' 0%, '+ this.$CHANGEA+' 100%)'} "
						@tap="confirmBuy(0)">确认</button>
				</view>
				<!-- <view class="btn-box foot_box u-flex u-row-between" v-else>
					<button class="u-reset-button cu-btn  cart-btn" @tap="confirmCart">加入购物车</button>
					<button class="u-reset-button cu-btn  buy-btn" @tap="confirmBuy">立即购买</button>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	/**
	 * 多规格组件
	 * @property {Object} goodsInfo - 商品数据
	 * @property {Boolean} value = showModal - 显隐
	 * @property {String} buyType  - 购买方式
	 * @property {String} goodsType - 商品类别
	 * @property {String} grouponBuyType -拼团商品购买方式
	 * @property {Number} grouponId - 拼团ID,分享进入
	 * @property {Object} activityRules - 活动状态。
	 */
	import { mapMutations, mapActions, mapState } from 'vuex';
	export default {
		components: {},
		data() {
			return {
				maxStep: 999,
				params: [],
				unitStr:'',
				// colors: [],
				// currentSkuPrice: {},
				currentSkuArray: [],
				goodsNum: 1,
				// confirmGoodsInfo: {},
				// type: this.buyType,
				indexs:{
					tcInex:0,
					clIndex:0,
					zqIndex:0,
					bbIndex:0,
					insIndex:0,
				},
				aliChecked:2,
				clickStyle:'border: 1rpx solid '+ this.$COLOR+',color: '+this.$COLOR+',background-color:#fff',
				defaultStyle:'',
				detail:{},
				datailStr:'',
				versionStr:'',
				commodityStr:'',
				pastType: ['99新', "95新", "9成新", "85新", "8成新","75新","7成新"],
			};
		},
		props: {
			goodsInfo: {},
			value: {},
			// buyType: {
			// 	type: String,
			// 	default: 'sku'
			// },
			// goodsType: {
			// 	type: String,
			// 	default: 'goods'
			// },
			// grouponBuyType: {
			// 	type: String,
			// 	default: 'alone'
			// },
			// grouponId: {
			// 	//参加拼团的时候，传入当前团id;
			// 	type: Number,
			// 	default: 0
			// }
		},
		created() {
			this.params = this.goodsInfo.params;
			console.log(123123,this.params)
			this.init()
			// this.changeDisabled(false);
		},
		mounted() {
			// 单规格选项
			// if (!this.goodsInfo.is_sku) {
			// 	this.currentSkuPrice = this.skuPrice[0];
			// 	this.maxStep = this.skuPrice[0].stock > 999 ? 999 : this.skuPrice[0].stock;
			// }
		},
		// watch: {
		// 	type(nweVal, oldVal) {
		// 		return newVal;
		// 	}
		// },
		computed: {
			// skuPrice() {
			// 	return this.goodsInfo.sku_price;
			// },
			showModal: {
				get() {
					return this.value;
				},
				set(val) {
					val ? uni.hideTabBar() : uni.showTabBar();
					this.$emit('input', val);
					return val;
				}
			},
			// currentSkuText() {
			// 	let that = this;
			// 	let str = '';
			// 	let currentSkuArray = this.currentSkuArray;
			// 	currentSkuArray.forEach(v => {
			// 		that.skuList.forEach(s => {
			// 			s.content.forEach(u => {
			// 				if (u.id === v) {
			// 					str += ' ' + u.name;
			// 				}
			// 			});
			// 		});
			// 	});
			// 	that.$emit('getSkuText', str);
			// 	return str;
			// },
			// termList() {
			// 	return this.params[this.indexs.tcInex].term_list
			// },
			// specificationsList() {
			// 	return this.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications
			// } 
		},

		methods: {
			// ...mapActions(['addCartGoods', 'getCartList']),
			jump(path, parmas) {
				console.log('jump',parmas)
				this.$Router.push({
					path: path,
					query: parmas
				});
				
			},
			init() {
				if(this.goodsInfo.smash){
					this.indexs.insIndex =this.goodsInfo.smash
				}
				// this.currentSkuArray = {
				// 	params : this.goodsInfo.params,
				// 	colors : this.goodsInfo.colors,
				// 	termList : this.params[this.indexs.tcInex].term_list,
				// 	// specificationsList : this.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications
				// }
				
				this.selected()
			},
			selected(){
				console.log("selected",this.goodsInfo)
				this.img = this.goodsInfo.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].imgUrl ? this.goodsInfo.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].imgUrl : this.goodsInfo.slideshows[0]
				if(this.aliChecked == 2){
					this.goodsInfo.price = (this.goodsInfo.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].money /  100).toFixed(2)
				}else{
					this.goodsInfo.price = (this.goodsInfo.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].sellPrice /  100).toFixed(2)
				}
				this.goodsInfo.img = this.img
				this.versionStr = this.goodsInfo.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].color
				console.log('已选',this.versionStr)
				
				// if(this.currentSkuArray.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].name == '24周'){
				// 	this.unitStr = '/周'
				// }else{
				// 	this.unitStr = '/天'
				// }
				// this.commodityStr = this.currentSkuArray.colors[this.indexs.clIndex].tit +" "+ this.currentSkuArray.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[0].tit +" "+ (this.goodsInfo.type ? "二手":"全新")
			},
			detialRefresh() {
				this.detail = {
					// 商品标题
					title:this.goodsInfo.tit,
					// 商品Id
					id:this.goodsInfo.id,
					// 优惠券
					clipCoupons:this.goodsInfo.clipCoupons ? this.goodsInfo.clipCoupons : 0,
					model:{
						// 价格
						price:this.currentSkuArray.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].money,
						// 租期
						leaseTerm:this.currentSkuArray.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].value
					},
					// 押金
					deposit:this.currentSkuArray.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].cash,
					buyOutPrice:this.currentSkuArray.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].buyout,
					purchasePrice:this.currentSkuArray.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].purchase,
					image:this.colors[this.indexs.clIndex].imgUrl,
					detail:this.datailStr,
					smash:this.goodsInfo.smash,
				}
			},
			// 支付方式选择
			checkedTap(e) {
			    this.aliChecked = e
			    console.log("支付方式",this.aliChecked)
				this.selected()
			    
			  },
			// 选择规格
			chooseSku(tit, index) {
				// 使用indexs中下标得方式选中
				
				if(tit == 'params') { 
					// 套餐
					this.indexs.tcInex = index
				} else if(tit == 'colors') {
					this.indexs.clIndex = index
					// 颜色
				} else if(tit == 'termList') {
					// 租期
					this.indexs.zqIndex = index
				} else if(tit == 'specificationsList') {
					// 版本
					this.indexs.bbIndex = index
				} else if(tit === 'insIndex'){
					if (this.indexs.insIndex != 0) {
					    this.indexs.insIndex = 0
					} else {
						this.indexs.insIndex = index
					}
				}
				console.log('碎屏',this.indexs.insIndex)
				this.selected()
				// 更改属性方式
				// var arr = this.currentSkuArray[tit][index]
				// var currentSkuArray = this.currentSkuArray[tit].map(function(item, mapIndex) {
				//     if(index == mapIndex){
				// 		item.click = true;	
				// 	}else{
				// 		item.click = false;
				// 	}
				//     return item;
				// })
				// this.currentSkuArray[tit] = []
				// this.currentSkuArray[tit] = currentSkuArray
				// // this.$set(this.currentSkuArray[tit],currentSkuArray);
				// console.log(arr)
				// if(tit === 'params'){
				// 	this.goodsInfo.price = this.currentSkuArray[tit][index].term_list[0]
				// }
				
				
				
				
				//===================================
				let that = this;
				let isChecked = true; // 选中 or 取消选中
				this.goodsNum = 1; //选择规格时，数量重置为1.
				this.maxStep = 999; //选择其他规格时，取消上个规格库存限制

				// if (that.currentSkuArray[pid] != undefined && that.currentSkuArray[pid] == skuId) {
				// 	// 点击已被选中的，删除并填充 ''
				// 	isChecked = false;
				// 	that.currentSkuArray.splice(pid, 1, '');
				// } else {
				// 	// 选中
				// 	that.$set(that.currentSkuArray, pid, skuId);
				// }

				// let chooseSkuId = []; // 选中的规格大类
				// that.currentSkuArray.forEach(sku => {
				// 	if (sku != '') {
				// 		// sku 为空是反选 填充的
				// 		chooseSkuId.push(sku);
				// 	}
				// });

				// // 当前所选规格下，所有可以选择的 skuPric
				// let newPrice = this.getCanUseSkuPrice();

				// // 判断所有规格大类是否选择完成
				// if (chooseSkuId.length == that.skuList.length && newPrice.length) {
				// 	that.currentSkuPrice = newPrice[0];
				// } else {
				// 	that.currentSkuPrice = {};
				// }

				// // 改变规格项禁用状态
				// this.changeDisabled(isChecked, pid, skuId);
			},

			// 改变禁用状态
			// changeDisabled(isChecked = false, pid = 0, skuId = 0) {
			// 	let newPrice = []; // 所有可以选择的 skuPrice

			// 	if (isChecked) {
			// 		// 选中规格

			// 		// 当前点击选中规格下的 所有可用 skuPrice
			// 		for (let price of this.skuPrice) {
			// 			if (price.stock <= 0) {
			// 				// this.goodsNum 不判断是否大于当前选择数量，在 uni-number-box 判断，并且 取 stock 和 goods_num 的小值
			// 				continue;
			// 			}
			// 			if (price.goods_sku_id_arr.indexOf(skuId.toString()) >= 0) {
			// 				newPrice.push(price);
			// 			}
			// 		}
			// 	} else {
			// 		// 取消选择规格

			// 		// 当前所选规格下，所有可以选择的 skuPric
			// 		newPrice = this.getCanUseSkuPrice();
			// 	}

			// 	// 所有存在并且有库存未选择的规格项 的 子项 id
			// 	let noChooseSkuIds = [];
			// 	for (let price of newPrice) {
			// 		noChooseSkuIds = noChooseSkuIds.concat(price.goods_sku_id_arr);
			// 	}

			// 	// 去重
			// 	noChooseSkuIds = Array.from(new Set(noChooseSkuIds));

			// 	if (isChecked) {
			// 		// 去除当前选中的规格项
			// 		let index = noChooseSkuIds.indexOf(skuId.toString());
			// 		noChooseSkuIds.splice(index, 1);
			// 	} else {
			// 		// 循环去除当前已选择的规格项
			// 		this.currentSkuArray.forEach(sku => {
			// 			if (sku.toString() != '') {
			// 				// sku 为空是反选 填充的
			// 				let index = noChooseSkuIds.indexOf(sku.toString());
			// 				if (index >= 0) {
			// 					// sku 存在于 noChooseSkuIds
			// 					noChooseSkuIds.splice(index, 1);
			// 				}
			// 			}
			// 		});
			// 	}

			// 	// 当前已选择的规格大类
			// 	let chooseSkuKey = [];
			// 	if (!isChecked) {
			// 		// 当前已选择的规格大类
			// 		this.currentSkuArray.forEach((sku, key) => {
			// 			if (sku != '') {
			// 				// sku 为空是反选 填充的
			// 				chooseSkuKey.push(key);
			// 			}
			// 		});
			// 	} else {
			// 		// 当前点击选择的规格大类
			// 		chooseSkuKey = [pid];
			// 	}

			// 	for (let i in this.skuList) {
			// 		// 当前点击的规格，或者取消选择时候 已选中的规格 不进行处理
			// 		if (chooseSkuKey.indexOf(this.skuList[i]['id']) >= 0) {
			// 			continue;
			// 		}

			// 		for (let j in this.skuList[i]['content']) {
			// 			// 如果当前规格项 id 不存在于有库存的规格项中，则禁用
			// 			if (noChooseSkuIds.indexOf(this.skuList[i]['content'][j]['id'].toString()) >= 0) {
			// 				this.skuList[i]['content'][j]['disabled'] = false;
			// 			} else {
			// 				this.skuList[i]['content'][j]['disabled'] = true;
			// 			}
			// 		}
			// 	}
			// },
			// 当前所选规格下，获取所有有库存的 skuPrice
			getCanUseSkuPrice() {
				let newPrice = [];

				for (let price of this.skuPrice) {
					if (price.stock <= 0) {
						// || price.stock < this.goodsNum		不判断是否大于当前选择数量，在 uni-number-box 判断，并且 取 stock 和 goods_num 的小值
						continue;
					}
					var isOk = true;

					this.currentSkuArray.forEach(sku => {
						// sku 不为空，并且，这个 条 skuPrice 没有被选中,则排除
						if (sku.toString() != '' && price.goods_sku_id_arr.indexOf(sku.toString()) < 0) {
							isOk = false;
						}
					});

					if (isOk) {
						newPrice.push(price);
					}
				}

				return newPrice;
			},
			
			// 数量
			changeNum(e) {
				// this.changeDisabled(false);
			},
			// 增加
			plus(e) {
				if (e.value >= this.currentSkuPrice.stock) {
					this.maxStep = this.currentSkuPrice.stock;
					this.$u.toast('库存不足');
					return;
				}
				if (this.goodsInfo.activity_type === 'seckill' || this.goodsInfo.activity_type === 'groupon') {
					let rules = this.goodsInfo.activity.rules;
					if (rules.limit_buy != 0 && e.value >= rules.limit_buy) {
						this.maxStep = rules.limit_buy;
						this.$u.toast('本次活动最多购买' + rules.limit_buy + '件');
						return;
					}
				}
			},

			// 加入购物车确定
			// confirmCart() {
			// 	let that = this;
			// 	if (this.confirmSku()) {
			// 		let confirmGoodsList = {
			// 			list: [that.confirmGoodsInfo],
			// 			from: 'goods'
			// 		};
			// 		that.addCartGoods(confirmGoodsList).then(res => {
			// 			if (res.code === 1) {
			// 				that.showModal = false;
			// 				that.$u.toast(res.msg);
			// 			}
			// 		});
			// 	}
			// },
			// 立即购买
			confirmBuy(val) {
				// let stock = this.currentSkuArray.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].stock
				// console.log(stock)
				// if (!parseInt(stock)) {
				// 	this.$u.toast('该商品缺货中');
				// 	return false
				// }
				// console.log(cobIndex,terIndex,verIndex,colIndex,insIndex)
				console.log('商品信息',this.goodsInfo)
				var urlImg = this.goodsInfo.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].imgUrl ? this.goodsInfo.params[this.indexs.tcInex].term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].imgUrl : this.goodsInfo.slideshows[0]
				var params = this.goodsInfo.params[this.indexs.tcInex]
				console.log('商品规格',params)
				let obj = {
				  msg: this.goodsInfo.tit,  // 商品名
				  id: this.goodsInfo.id,  // 商品id
				  sid: this.goodsInfo.sid,
				  skuId: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].skuId,
				  version: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].version,
				  detail:params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].color,   // 套餐
				  shoppingType:this.goodsInfo.productType,

				  trem: params.term_list[this.indexs.zqIndex].name, // 租期
				  trem_value: params.term_list[this.indexs.zqIndex].value, // 租期
				   // urlImg.replace(/%/g, '%25').replace(/&/g, '%26'),
				  slideshows:urlImg.replace(/%/g, '%25').replace(/&/g, '%26'),
				  deductionInterval:parseInt(this.goodsInfo.deductionInterval), // 账单时间间隔
				//promotionType pastType
				  pastType:this.pastType[this.goodsInfo.pastType],//二手标签几几新
				  staShow :params.name,
				  price: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].money,//金额
				  neicun: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].tit,//内存

				  cash: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].cash,//押金
				  money: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].money,//金额
				  buyOut: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].buyout, // 完结价
				  purchase: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].purchase, // 采购价
				  cycle: params.term_list[this.indexs.zqIndex].title,//周期
				  termUnit: params.term_list[this.indexs.zqIndex].termUnit,//周期单位
				  sellPrice: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].sellPrice,//售卖金额

				  // zprice: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].money + this.goodsInfo.smash,
				  wangluo: this.goodsInfo.category.wangluo,  //网络
				  color: params.term_list[this.indexs.zqIndex].specifications[this.indexs.bbIndex].color,//颜色
				  // img:this.img,
				  type:this.goodsInfo.type, // 成色 0为新，1为二手
				  match: { tit: this.goodsInfo.match, value: this.goodsInfo.match },  // 可选搭配
				  smash: this.indexs.insIndex,  //加工费
				  freight: this.goodsInfo.freight ? '到付' : "包邮",
				  // shops: this.data.data.shops,
				  aliChecked:this.aliChecked,
				  promotionType:0,
				  saleQuantity: 1,
				  clickId:this.goodsInfo.clickId
				}
				// console.log(obj.color)
				// obj.color.imgUrl.replace(/%/g, '%25').replace(/&/g, '%26')
				var data = encodeURIComponent(JSON.stringify(obj));
				console.log("sku",obj)
				uni.navigateTo({
				    url:`/pages/order/confirm?data=`+ data
				})
				// this.jump('/pages/order/confirm', name);
				//判断能不能用商家券
				// if(this.data.comePath == "ticket"){
				//   obj.clipCoupons = 1
				// }
				//判断是否是测试商品
				// if(this.data.comePath == "testGoods"){
				//   obj.testOrder = 2
				// }else{
				//   obj.testOrder = 1
				// }
				// this.$Router.push({
				// 	path: '/pages/order/confirm',
				// 	query:  {data:JSON.stringify(obj)},
				
				// });
				
			
				// let that = this;
				// that.showModal = false;
				// if (this.confirmSku()) {
				// 	let confirmGoodsList = [];
				// 	confirmGoodsList.push(that.confirmGoodsInfo);
				// 	that.jump('/pages/order/confirm', {
				// 		goodsList: confirmGoodsList,
				// 		from: 'goods',
				// 		orderType: that.goodsType,
				// 		grouponBuyType: that.grouponBuyType,
				// 		grouponId: that.grouponId
				// 	});
				// }
			},
			// 确定
			// confirm() {
			// 	if (this.confirmSku()) {
			// 		switch (this.buyType) {
			// 			case 'cart':
			// 				this.confirmCart();
			// 				break;
			// 			case 'buy':
			// 				this.confirmBuy();
			// 				break;
			// 			default:
			// 		}
			// 	}
			// },
			// 确定规格
			// confirmSku() {
			// 	let that = this;
			// 	if (that.currentSkuPrice.stock == 0 || that.currentSkuPrice.stock < that.goodsNum) {
			// 		that.$u.toast('库存不足');
			// 		that.showModal = false;
			// 		return false;
			// 	} else {
			// 		that.currentSkuPrice.goods_num = that.goodsNum;
			// 		that.confirmGoodsInfo = {
			// 			goods_id: that.currentSkuPrice.goods_id,
			// 			goods_num: that.currentSkuPrice.goods_num,
			// 			sku_price_id: that.currentSkuPrice.id,
			// 			goods_price: that.currentSkuPrice.price
			// 		};
			// 		if (!that.confirmGoodsInfo.sku_price_id) {
			// 			that.$u.toast('请选择规格');
			// 			return false;
			// 		} else {
			// 			that.showModal = false;
			// 			return true;
			// 		}
			// 	}
			// }
		}
	};
</script>

<style lang="scss" scoped>
	.size-box {
		line-height: 82rpx;
		background: #fff;
		padding: 0 20rpx;
		margin: 20rpx 0;
		font-size: 28rpx;

		.title {
			color: #999;
			margin-right: 20rpx;
		}
	}
	.select-combo {
	  font-size: 28rpx;
	  // font-weight: 400;
	  color: #999999;
	  // line-height: 40rpx;
	  // margin-top: 4rpx;
	  letter-spacing: 1rpx;
	  // margin: 0rpx,10rpx,0rpx;
	}
	// 规格
	.shop-modal {
		width: 750rpx;
		height: 950rpx;
		background: rgba(255, 255, 255, 1);
		padding: 20rpx 20rpx 30rpx;
		position: relative;

		.close-icon {
			font-size: 34rpx;
			color: #e0e0e0;
			position: absolute;
			top: 20rpx;
			right: 20rpx;
		}

		// 商品卡片
		.top {
			margin: 30rpx 0;
			border-radius: 20rpx;
			padding: 20rpx;

			.shop-img {
				width: 160upx;
				height: 160upx;
				border-radius: 6upx;
				margin-right: 30upx;
				background: #ccc;
			}

			.goods-box {
				height: 150upx;
				width: 490rpx;
				align-items: flex-start;

				.goods-title {
					font-size: 28rpx;

					font-weight: 500;
					color: rgba(51, 51, 51, 1);
					line-height: 42rpx;
					text-align: left;
				}

				.goods-bottom {
					width: 100%;
				}

				.price-box {
					font-size: 36upx;

					font-weight: bold;
					color: #e1212b;

					.unit {
						font-size: 24upx;

						font-weight: bold;
						color: #e1212b;
					}
				}

				.stock {
					font-size: 26rpx;
					color: #999;
				}
			}
		}

		// 规格选项
		.select-box {
			margin-bottom: 30rpx;

			.type-title {
				font-size: 26upx;
				font-weight: 400;
				margin-bottom: 20upx;
			}

			.tag-box {
				flex-wrap: wrap;
			}

			.tag {
				line-height: 62rpx;
				background: #f4f4f4;
				border-radius: 31rpx;
				font-size: 28upx;
				font-weight: 400;
				color: #666666;
				padding: 0 30upx;
				margin-bottom: 20rpx;
				margin-right: 10rpx;
			}

			.tag-active {
				    background-color: #fff;
				    border: 1rpx solid #55aaff;
				    color: #55aaff;
				    font-weight: bold;
			}

			.tag-disabled {
				background: #f8f8f8;
				color: #cacaca;
			}
		}

		.buy-num-box {
			.num-title {
				font-size: 26upx;

				font-weight: 400;
				margin-bottom: 20upx;
			}
		}
	}

	.btn-box {
		height: 100rpx;

		.cu-btn {
			width: 340rpx;
			line-height: 70rpx;
			border-radius: 35rpx;
			font-size: 28rpx;

			font-weight: 500;
			color: rgba(255, 255, 255, 0.9);
			padding: 0;
		}

		.cart-btn {
			background: linear-gradient(90deg, rgba(103, 104, 105, 1), rgba(82, 82, 82, 1));
			box-shadow: 0px 2rpx 5rpx 0px rgba(102, 103, 104, 0.46);
		}

		.buy-btn {
			background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
		}

		.save-btn {
			width: 710rpx;
			height: 70rpx;
			background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
			font-size: 28rpx;
			font-weight: 500;
			color: rgba(255, 255, 255, 1);
			border-radius: 35rpx;
			padding: 0;
		}

		.cancel-btn {
			width: 710rpx;
			height: 70rpx;
			background: rgba(221, 221, 221, 1);
			font-size: 28rpx;
			font-weight: 500;
			color: #999999;
			border-radius: 35rpx;
			padding: 0;
		}
	}
	
	
	.selectNumWrap{
	  display: flex;
	  justify-content: space-between;
	  align-items: center;
	  margin-top: 30rpx;
	}
	.selectNum{
	  background-color: #fff;
	  border: 1rpx solid #1677FF;
	  color: #1677FF;
	  font-weight: bold;
	  font-size: 30rpx;
	  height: 60rpx;
	  border-radius: 30rpx;
	  display: flex;
	  justify-content: space-between;
	  align-items: center;
	}
	
	.recommend{
	  margin-left:20rpx;
	  background-color:#fe0000;
	  width:85rpx;
	  height:40rpx;
	  line-height: 20rpx;
	  border: 0.5px solid #fe0000;
	  border-radius: 10px;padding: 5px;
	  display: inline-block
	  ;color:#FFF;
	  text-align:center;
	  font-size:25rpx;
	}
	.buttonRecommend{
		margin-left:20rpx;
		background-color:#fe0000;
		width:150rpx;
		height:50rpx;
		line-height: 30rpx;
		border: 0.5px solid #fe0000;
		border-radius: 10px;padding: 5px;
		display: inline-block
		;color:#FFF;
		text-align:center;
		font-size:25rpx;
	}
	.checkbox-circle {
	  /* position: absolute; */
	  /* transform: translateY(-100%); */
	  right: 50rpx;
	  width: 40rpx; /* 圆形的大小 */
	  height: 40rpx;
	  border-radius: 50%; /* 设置为50%使其成为圆形 */
	  border: 1rpx solid rgb(133, 127, 127); /* 可选：设置边框颜色和宽度 */
	  display: flex;
	  justify-content: center;
	  align-items: center;
	  color: #FFF; /* 勾选标记的颜色 */
	}
	.select_true{
	  width: 50rpx; /* 圆形的大小 */
	  height: 40rpx;
	 
	}
</style>
